package edu.tongji.engine.def;

import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

/**
 * 
 * @author David Fei
 *
 */
/**
 * This class describe a process definition. All Workflows need this class to define themselves.
 * 
 */
public class ProcessDefinition {

	private Long id;
	
	private String name;
	
	private String description;
	
	private Node startNode;
	
	private Set nodes = new HashSet(0);

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Set getNodes() {
		return nodes;
	}

	public void setNodes(Set nodes) {
		this.nodes = nodes;
	}
	
//	public Node getRootNode(){
//		return startNode;
//		//return (Node)nodes.iterator().next();
//	}
	
	public void addNode(Node node){
		if (node == null) throw new IllegalArgumentException("can't add a null node to a processdefinition");

	    nodes.add(node);

	}

//	public Node getStartNode() {
//		Iterator iterator = nodes.iterator();
//		while(((Node)iterator.next()).getType_name().equals("StartNode")){
//			return (Node)iterator;
//		}
//		return (Node)nodes.iterator().next();
//	}

	public Node getStartNode() {
		return this.startNode;
	}
	public void setStartNode(Node startNode) {
		this.startNode = startNode;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}
}
